<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获取视口尺寸</title>
    <script>
        function getWdithHeight () {
            var width = window.innerWidth || document.documentElement.clientWidth ||document.body.clientWidth;
            var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
            document.writeln("此视口宽度为：" + width + "px");
            document.write("此视口高度为：" + height + "px");
        }
    </script>
</head>
<body>
    <input type="button" onclick="getWdithHeight()" value="点我查看窗口尺寸">
</body>
</html>